<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            list-style: none;
            line-height: 45px;
            border: 1px dashed #333;
            margin-top: 10px;
            text-indent: 10px;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <button class="add">新增</button>
        <div class="list">
            <li>01</li>
            <li>02</li>
            <li>03</li>
            <li>04</li>
            <li>05</li>
            <li>06</li>
        </div>
    </div>
</body>
<script>
    var add = document.getElementsByClassName("add")[0];
    var list = document.getElementsByClassName("list")[0];
    var liList = list.getElementsByTagName("li");

    add.onclick = function (){
        var li = document.createElement("li");
        li.innerText = "新增li";
        list.appendChild(li);
    }

    // for(var i = 0 ; i < liList.length ; i++){
    //     var li = liList[i];
    //     li.onclick = function (){
    //         var index = Array.from(liList).indexOf(this);
    //         console.log(this.textContent , index);
    //     }
    // }

    list.onclick = function (event){
        var event = event || window.event;
        var target = event.target || event.srcElement;
        console.log(target);
    }
</script>

</html>